// 订单管理假数据 - 增加更多数据用于演示分页功能
export const mockOrderData = [
  {
    id: 1,
    orderTime: "2025-10-25 14:32",
    medicineName: "布洛芬片",
    quantity: "50盒",
    orderer: "张伟",
    customerName: "广州恒信药房",
    contact: "13800138000",
    address: "广州市天河区中山大道888号",
    expressCompany: "顺丰速运",
    trackingNumber: "SF1234567890",
    status: "已发出",
    updateTime: "2025-10-25 18:20"
  },
  {
    id: 2,
    orderTime: "2025-10-25 10:12",
    medicineName: "维生素C片",
    quantity: "80瓶",
    orderer: "李婷",
    customerName: "深圳康宁药房",
    contact: "13900139000",
    address: "深圳市南山区科技园南路88号",
    expressCompany: "京东物流",
    trackingNumber: "JD987654321",
    status: "运输中",
    updateTime: "2025-10-26 09:00"
  },
  {
    id: 3,
    orderTime: "2025-10-24 09:48",
    medicineName: "氯雷他定片",
    quantity: "30盒",
    orderer: "王强",
    customerName: "东莞民安药房",
    contact: "13700137000",
    address: "东莞市松山湖科技二路16号",
    expressCompany: "圆通速递",
    trackingNumber: "YT4455667788",
    status: "派送中",
    updateTime: "2025-10-26 12:30"
  },
  {
    id: 4,
    orderTime: "2025-10-24 11:25",
    medicineName: "阿莫西林胶囊",
    quantity: "100盒",
    orderer: "陈明",
    customerName: "佛山健康大药房",
    contact: "13600136001",
    address: "佛山市禅城区祖庙路123号",
    expressCompany: "中通快递",
    trackingNumber: "ZT1122334455",
    status: "已揽收",
    updateTime: "2025-10-24 12:00"
  },
  {
    id: 5,
    orderTime: "2025-10-23 16:40",
    medicineName: "头孢克肟胶囊",
    quantity: "40盒",
    orderer: "刘芳",
    customerName: "珠海阳光药房",
    contact: "13500135002",
    address: "珠海市香洲区情侣南路456号",
    expressCompany: "韵达快递",
    trackingNumber: "YD6677889900",
    status: "已签收",
    updateTime: "2025-10-25 10:30"
  },
  {
    id: 6,
    orderTime: "2025-10-23 08:15",
    medicineName: "奥美拉唑肠溶胶囊",
    quantity: "60瓶",
    orderer: "黄华",
    customerName: "中山惠民药房",
    contact: "13400134003",
    address: "中山市石岐区孙文中路789号",
    expressCompany: "申通快递",
    trackingNumber: "ST1122334456",
    status: "运输中",
    updateTime: "2025-10-24 15:20"
  },
  {
    id: 7,
    orderTime: "2025-10-22 13:55",
    medicineName: "复方甘草片",
    quantity: "200盒",
    orderer: "赵敏",
    customerName: "江门福康药房",
    contact: "13300133004",
    address: "江门市蓬江区建设路101号",
    expressCompany: "百世快递",
    trackingNumber: "BS5566778899",
    status: "派送中",
    updateTime: "2025-10-25 14:00"
  },
  {
    id: 8,
    orderTime: "2025-10-22 09:30",
    medicineName: "硝苯地平缓释片",
    quantity: "30盒",
    orderer: "杨军",
    customerName: "肇庆康泰药房",
    contact: "13200132005",
    address: "肇庆市端州区建设二路234号",
    expressCompany: "EMS",
    trackingNumber: "EM1122334455",
    status: "已发出",
    updateTime: "2025-10-23 16:45"
  },
  {
    id: 9,
    orderTime: "2025-10-21 14:20",
    medicineName: "盐酸二甲双胍片",
    quantity: "90盒",
    orderer: "周丽",
    customerName: "惠州康健药房",
    contact: "13100131006",
    address: "惠州市惠城区麦地路567号",
    expressCompany: "顺丰速运",
    trackingNumber: "SF9988776655",
    status: "已签收",
    updateTime: "2025-10-22 09:10"
  },
  {
    id: 10,
    orderTime: "2025-10-21 16:05",
    medicineName: "板蓝根颗粒",
    quantity: "150盒",
    orderer: "吴强",
    customerName: "清远民康药房",
    contact: "13000130007",
    address: "清远市清城区新城路890号",
    expressCompany: "圆通速递",
    trackingNumber: "YT4455667733",
    status: "运输中",
    updateTime: "2025-10-24 11:30"
  },
  {
    id: 11,
    orderTime: "2025-10-20 10:40",
    medicineName: "感冒灵颗粒",
    quantity: "120盒",
    orderer: "林燕",
    customerName: "韶关医药连锁",
    contact: "13911139111",
    address: "韶关市武江区工业中路321号",
    expressCompany: "中通快递",
    trackingNumber: "ZT5544332211",
    status: "已发出",
    updateTime: "2025-10-21 13:45"
  },
  {
    id: 12,
    orderTime: "2025-10-20 15:25",
    medicineName: "阿司匹林肠溶片",
    quantity: "75盒",
    orderer: "郑伟",
    customerName: "河源医药总汇",
    contact: "13822238222",
    address: "河源市源城区越王大道654号",
    expressCompany: "韵达快递",
    trackingNumber: "YD6677889911",
    status: "派送中",
    updateTime: "2025-10-23 16:20"
  }
];

// 模拟分页数据
export function getMockOrderList(queryParams, pageNum, pageSize) {
  // 根据查询参数过滤数据
  let filteredData = mockOrderData;
  
  // 根据下单人过滤
  if (queryParams.orderer) {
    filteredData = mockOrderData.filter(order => 
      order.orderer.includes(queryParams.orderer)
    );
  }
  
  // 根据日期范围过滤
  if (queryParams.beginTime && queryParams.endTime) {
    filteredData = filteredData.filter(order => {
      const orderDate = new Date(order.orderTime);
      const beginDate = new Date(queryParams.beginTime);
      const endDate = new Date(queryParams.endTime);
      return orderDate >= beginDate && orderDate <= endDate;
    });
  }
  
  // 计算分页
  const total = filteredData.length;
  const start = (pageNum - 1) * pageSize;
  const end = start + pageSize;
  const rows = filteredData.slice(start, end);
  
  return {
    rows: rows,
    total: total
  };
}

// 根据ID获取订单信息
export function getMockOrderById(id) {
  return mockOrderData.find(order => order.id === id);
}

// 获取快递信息
export function getMockShippingInfo(id) {
  const order = mockOrderData.find(order => order.id === id);
  if (order) {
    return {
      expressCompany: order.expressCompany,
      trackingNumber: order.trackingNumber,
      status: order.status,
      updateTime: order.updateTime
    };
  }
  return null;
}

// 模拟导入运单
export function mockImportWaybill(file) {
  // 这里可以添加实际的文件解析逻辑
  console.log("导入文件:", file);
  return true;
}

// 模拟导出订单
export function mockExportOrders(queryParams) {
  // 根据查询参数过滤数据
  let filteredData = mockOrderData;
  
  // 根据下单人过滤
  if (queryParams.orderer) {
    filteredData = mockOrderData.filter(order => 
      order.orderer.includes(queryParams.orderer)
    );
  }
  
  // 根据日期范围过滤
  if (queryParams.beginTime && queryParams.endTime) {
    filteredData = filteredData.filter(order => {
      const orderDate = new Date(order.orderTime);
      const beginDate = new Date(queryParams.beginTime);
      const endDate = new Date(queryParams.endTime);
      return orderDate >= beginDate && orderDate <= endDate;
    });
  }
  
  // 返回过滤后的数据
  return filteredData;
}